#define _XOPEN_SOURCE 
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<shadow.h>
#include<string.h>

int main(int argc,char **argv)
{
	char *inputpass;
	char *cryptpass;
	struct spwd *shadowline;
	if(argc<2)
	{
		fprintf(stderr,"input error\n");
		return -1;
	}
	inputpass= getpass("input password:\n");
	shadowline = getspnam(argv[1]);
	cryptpass=crypt(inputpass,shadowline->sp_pwdp);
	if(strcmp(shadowline->sp_pwdp,cryptpass)==0)
	{
		puts("ok\n");
	}
	else
		puts("failed\n");
	



	return 0;
}
